package com.yjzx.core.bean.sql;

import com.yjzx.core.bean.ConfigurationInfo;
import com.yjzx.core.bean.TemplatePath;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * @author guozhi
 * @date 2023/10/19
 * @description SqlConfigurationInfo
 */
public abstract class SqlConfigurationInfo extends ConfigurationInfo {
    /**
     * Ip
     */
    private String ip;

    /**
     * port
     */
    private String port;

    /**
     * driver
     */
    private String driver;

    /**
     * 数据库名
     */
    private String dataBase;

    /**
     * 编码
     */
    private String encoding;

    /**
     * 用户名
     */
    private String loginName;

    /**
     * 密码
     */
    private String passWord;
    /***
     * 需要处理的表名Map
     */
    private Map<String, String> includeMap;

    public SqlConfigurationInfo() {
    }

    public SqlConfigurationInfo(ConfigurationInfo config) {
        super(config.getEncoding(), config.getProjectName(), config.getProjectName(), config.getAuthorName(), config.getRootPath(), config.getProjectPath(), config.getTemplates());
    }

    public SqlConfigurationInfo(ConfigurationInfo config,String ip, String port, String driver, String dataBase, String encoding, String loginName, String passWord, Map<String, String> includeMap) {
        super(config.getEncoding(), config.getProjectName(), config.getProjectName(), config.getAuthorName(), config.getRootPath(), config.getProjectPath(), config.getTemplates());
        this.ip = ip;
        this.port = port;
        this.driver = driver;
        this.dataBase = dataBase;
        this.encoding = encoding;
        this.loginName = loginName;
        this.passWord = passWord;
        this.includeMap = includeMap;
    }

    public SqlConfigurationInfo(String encoding, String projectName, String packageName, String authorName, String rootPath, String projectPath, List<TemplatePath> templatePaths, String ip, String port, String driver, String dataBase, String encoding1, String loginName, String passWord, Map<String, String> includeMap) {
        super(encoding, projectName, packageName, authorName, rootPath, projectPath, templatePaths);
        this.ip = ip;
        this.port = port;
        this.driver = driver;
        this.dataBase = dataBase;
        this.encoding = encoding1;
        this.loginName = loginName;
        this.passWord = passWord;
        this.includeMap = includeMap;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public String getPort() {
        return port;
    }

    public void setPort(String port) {
        this.port = port;
    }

    public String getDriver() {
        return driver;
    }

    public void setDriver(String driver) {
        this.driver = driver;
    }

    public String getDataBase() {
        return dataBase;
    }

    public void setDataBase(String dataBase) {
        this.dataBase = dataBase;
    }

    @Override
    public String getEncoding() {
        return encoding;
    }

    @Override
    public void setEncoding(String encoding) {
        this.encoding = encoding;
    }

    public String getLoginName() {
        return loginName;
    }

    public void setLoginName(String loginName) {
        this.loginName = loginName;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }

    public Map<String, String> getIncludeMap() {
        return includeMap;
    }

    public void setIncludeMap(Map<String, String> includeMap) {
        this.includeMap = includeMap;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        if (!super.equals(o)) {
            return false;
        }
        SqlConfigurationInfo that = (SqlConfigurationInfo) o;
        return Objects.equals(ip, that.ip) && Objects.equals(port, that.port) && Objects.equals(driver, that.driver) && Objects.equals(dataBase, that.dataBase) && Objects.equals(encoding, that.encoding) && Objects.equals(loginName, that.loginName) && Objects.equals(passWord, that.passWord) && Objects.equals(includeMap, that.includeMap);
    }

    @Override
    public int hashCode() {
        return Objects.hash(super.hashCode(), ip, port, driver, dataBase, encoding, loginName, passWord, includeMap);
    }
}

